import { ResponseCode } from "./../../enum/appEnum";
import Mock from "mockjs2";
import { builder, getBody } from "../util";

const listQueryData = () => {
  const data = Mock.mock({
    "datas|1-60": [
      {
        "id|+1": () => Mock.mock("@guid"),
        "name|+1": () => Mock.mock("@cname"),
        "age|+1": () => Mock.mock("@integer(18, 45)"),
        "address|+1": () => Mock.mock("@csentence(3, 5)"),
        "tags|+1": ["标签1", "标签2"],
      },
    ],
  });
  return builder(data?.datas, "", ResponseCode.success, {
    "Custom-Header": Mock.mock("@guid"),
  });
};

const basicQuery = () => {
  const data = Mock.mock({
    "datas|1-60": [
      {
        "roleId|+1": () => Mock.mock("@integer(1000, 9999)"),
        "tenantId|+1": () => Mock.mock("@integer(1000, 9999)"),
        "roleCode|+1": () => Mock.mock("@string(25)"),
        "roleName|+1": () => Mock.mock("@ctitle"),
        "roleDesc|+1": () => Mock.mock("@csentence"),
        "createuser|+1": () => Mock.mock("@integer(6)"),
        "createtime|+1": () => Mock.mock("@datetime('yyyy-MM-dd HH:mm:ss')"),
      },
    ],
  });
  return builder(data?.datas, "", ResponseCode.success, {
    "Custom-Header": Mock.mock("@guid"),
  });
};
// 角色查询
const roldQuery = () => {
  const data = Mock.mock({
    "datas|1-60": [
      {
        "roleId|+1": () => Mock.mock("@integer(1000, 9999)"),
        "tenantId|+1": () => Mock.mock("@integer(1000, 9999)"),
        "roleCode|+1": () => Mock.mock("@string(25)"),
        "roleName|+1": () => Mock.mock("@ctitle"),
        "roleDesc|+1": () => Mock.mock("@csentence"),
        "createuser|+1": () => Mock.mock("@integer(6)"),
        "createtime|+1": () => Mock.mock("@datetime('yyyy-MM-dd HH:mm:ss')"),
      },
    ],
  });
  return builder(data?.datas, "", "777", {
    "Custom-Header": Mock.mock("@guid"),
  });
};
//  角色新增
const roleAdd = () => {
  return builder([], "新增成功", "777", {
    "Custom-Header": Mock.mock("@guid"),
  });
};
// 角色编辑
const roleUpdate = () => {
  return builder([], "更新成功", "777", {
    "Custom-Header": Mock.mock("@guid"),
  });
};
// 角色删除
const roleDel = () => {
  return builder([], "删除成功", "777", {
    "Custom-Header": Mock.mock("@guid"),
  });
};
const basicAdd = () => {
  return builder([], "新增成功", ResponseCode.success, {
    "Custom-Header": Mock.mock("@guid"),
  });
};
const basicUpdate = () => {
  return builder([], "更新成功", ResponseCode.success, {
    "Custom-Header": Mock.mock("@guid"),
  });
};
const basicDel = () => {
  return builder([], "删除成功", ResponseCode.success, {
    "Custom-Header": Mock.mock("@guid"),
  });
};
// 子系统配置 查询
const subsystemConfigQuery = {
  code: "777",
  msg: "成功",
  datas: [
    {
      key: 1,
      menuId: "1800",
      parentId: null,
      title: "子系统0001-u",
      name: "子系统0001-u",
      icon: null,
      menuOrder: "0",
      children: [
        {
          key: 11,
          menuId: "1801",
          parentId: "1800",
          title: "微应用0001",
          name: "微应用0001",
          icon: null,
          menuOrder: "0",
          children: [
            {
              key: 111,
              menuId: "1802",
              parentId: "1801",
              title: "菜单0001-up",
              name: "help",
              icon: "/test/test/0002.jpg",
              menuOrder: "0",
              children: null,
              menuCode: "test_menu_0001-up",
              menuDesc: null,
              isLeaf: "1",
              path: "/test_sys_0001-u/test_app_0001/test_menu_0001-up",
              rediret: "/help",
              tenantId: "default",
              funcCode: "M11_BZ",
              serverId: "test0001",
            },
          ],
          menuCode: "test_app_0001",
          menuDesc: null,
          isLeaf: "0",
          path: "/test_sys_0001-u/test_app_0001",
          rediret: "",
          tenantId: "default",
          funcCode: null,
          serverId: null,
        },
      ],
      menuCode: "test_sys_0001-u",
      menuDesc: null,
      isLeaf: "0",
      path: "/test_sys_0001-u",
      rediret: "",
      tenantId: "default",
      funcCode: null,
      serverId: null,
    },
    {
      key: 2,
      menuId: "1803",
      parentId: null,
      title: "子系统0002",
      name: "子系统0002",
      icon: "/test/test/0002.jpg",
      menuOrder: "0",
      children: [
        {
          menuId: "1804",
          parentId: "1803",
          title: "微应用0002",
          name: "微应用0002",
          icon: "/test/test/0001.jpg",
          menuOrder: "0",
          children: [
            {
              menuId: "1805",
              parentId: "1804",
              title: "菜单0002",
              name: "help",
              icon: "/test/test/0002.jpg",
              menuOrder: "0",
              children: null,
              menuCode: "1805",
              menuDesc: null,
              isLeaf: "1",
              path: "/test_sys_0002/test_app_0002/1805",
              rediret: "/help",
              tenantId: "default",
              funcCode: "M11_BZ",
              serverId: "test0001",
            },
          ],
          menuCode: "test_app_0002",
          menuDesc: null,
          isLeaf: "0",
          path: "/test_sys_0002/test_app_0002",
          rediret: "",
          tenantId: "default",
          funcCode: null,
          serverId: null,
        },
      ],
      menuCode: "test_sys_0002",
      menuDesc: null,
      isLeaf: "0",
      path: "/test_sys_0002",
      rediret: "",
      tenantId: "default",
      funcCode: null,
      serverId: null,
    },
  ],
  micuisInfo: [
    {
      micuiId: "M11_BZ",
      micuiName: "帮助",
      path: "/help",
    },
  ],
};
// 子系统配置 新增
const subsystemConfigAdd = () => {
  return builder([], "新增成功", 777, {
    "Custom-Header": Mock.mock("@guid"),
  });
};

Mock.mock(/\/base\/list\/query/, "post", listQueryData);

Mock.mock(/\/authManage000\/selectRole.xops/, "post", basicQuery);
Mock.mock(/\/authManage000\/addRole.xops/, "post", basicAdd);
Mock.mock(/\/authManage000\/updateRole.xops/, "post", basicUpdate);
Mock.mock(/\/authManage000\/deleteRole.xops/, "post", basicDel);

Mock.mock(/\/authManage000\/selectRole.xops/, "post", roldQuery); // 角色查询
Mock.mock(/\/authManage000\/addRole.xops/, "post", roleAdd); // 角色新增
Mock.mock(/\/authManage000\/updateRole.xops/, "post", roleUpdate); // 角色编辑
Mock.mock(/\/authManage000\/deleteRole.xops/, "post", roleDel); // 角色删除 roleDel
Mock.mock(/\/authManage000\/queryAppMenu.xops/, "post", subsystemConfigQuery); //  子系统配置 查询 queryAppMenu.xops
Mock.mock(/\/authManage000\/addAppMenu.xops/, "post", subsystemConfigAdd); //    子系统配置 新增
